<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Warnings extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('warnings', ['id'=>'id', 'comment'=>'预警表', 'engine'=>'innodb']);

        $table->addColumn('send_time', 'datetime', ['comment'=>'时间', 'null'=>true])
              ->addColumn('title', 'string', ['comment'=>'主题'])
              ->addColumn('content', 'text', ['comment'=>'内容'])
              ->addColumn('recipients', 'text', ['comment'=>'接收者'])
              ->addColumn('send_type', 'string', ['limit'=>10, 'default'=>'system', 'comment'=>'发布类型 system:系统, sms:短信'])
              ->addColumn('state', 'integer', ['limit'=>5, 'comment'=>'发送状态, 0:待发送, 1:发送成功, 2:撤回(发布类型为system可用)', 'default'=>0])
              ->addTimestamps()
              ->create();

    }
}
